var JS_CLICK = function(){
	var owner = this;
	owner.dom_tag = "click";
	owner.dom_search = $("#"+owner.dom_tag+"_div_search");
	owner.dom_table = $("#"+owner.dom_tag+"_table");
	owner.currentId = null;
	owner.currentRow = 0;
	owner.map_data = {};
	owner.map_enum = {"os_1":"ios", "os_2":"android", "os_3":"wp", "os_4":"other"};
	owner.box_os = [{text:"ios",value:1}, {text:"android",value:2}, {text:"wp",value:3}, {text:"other",value:4}];
	owner.isShowSearchWindow = false;
	
	owner.dom_table.datagrid({
		onSortColumn: function(sort, order){
			owner.sortName = sort;
			owner.sortOrder = true?(order=="asc"):false;
			owner.getPage(1);
		}
	}).datagrid("getPager").pagination({
	    layout: ["list","sep","first","prev","sep","manual","sep","next","last","refresh","sep"],
	    pageList: [10,20,50,100],
	    pageSize: 20,
	    buttons: [{
	        iconCls:"icon-search",
	        handler:function(){
	            owner.dom_search.window("open").window("hcenter");
	            if(!owner.isShowSearchWindow) {
	            	$("#ipt_"+owner.dom_tag+"_search_begin").Zebra_DatePicker({
	            		direction: ['2014-09-18', false],
	            		enableHour: false
					});
	            	$("#ipt_"+owner.dom_tag+"_search_company").combobox("loadData", GLOBAL.getCompanyMatchList(true));
	            	$("#ipt_"+owner.dom_tag+"_search_ad").combobox("loadData", GLOBAL.getAdMatchList(true));
					$("#ipt_"+owner.dom_tag+"_search_os").combobox("loadData", owner.box_os).combobox("clear");
					owner.isShowSearchWindow = true;
	            }
	        }
	    }],
	    onSelectPage: function(pageNum, pageSize){
	    	owner.getPage(pageNum, pageSize);
	    }
	}); 
	
	owner.init = function(){
		if(window.localStorage.getItem("adminRoleName")!="超级管理员") {
			$("#ipt_"+owner.dom_tag+"_search_company").parent().hide();
			owner.dom_table.datagrid("hideColumn", "p1");
		}
	};
	
	owner.resetSearch = function(){
		owner.dom_search.find(".easyui-textbox").textbox("clear")
		.end().find(".easyui-combobox").combobox("clear")
		.end().find(".easyui-combotree").combotree("clear")
		.end().find(".easyui-numberbox").numberbox("clear")
		.end().find(".textbox").val("");
	};
	
	owner.formatItem = function(obj){
		var item = {
			"itemId": obj.clickId,
			"p1": obj.clickCompanyName,
			"p2": obj.clickAdName,
			"p3": owner.map_enum["os_"+obj.clickOs],
			"p4": obj.clickTimes,
			"addTime": obj.addTime.date()
		};
		return item;
	};
	
	owner.getPage = function(pageNum, pageSize){
		if(pageSize==null) {
			pageSize = owner.dom_table.datagrid("getPager").pagination("options").pageSize;
		}
		var params = {};
		if(!owner.isShowSearchWindow) {
			params = {
				"searchCompany": "", 
				"searchAd": "", 
				"searchOs": "", 
				"searchDay": "",
				"pageNum": pageNum,
				"pageSize": pageSize
			};
		} else {
			params = {
				"searchCompany": $("#ipt_"+owner.dom_tag+"_search_company").combobox("getValue"), 
				"searchAd": $("#ipt_"+owner.dom_tag+"_search_ad").combobox("getValue"), 
				"searchOs": $("#ipt_"+owner.dom_tag+"_search_os").combobox("getValue"), 
				"searchDay": $("#ipt_"+owner.dom_tag+"_search_begin").val(),
				"pageNum": pageNum,
				"pageSize": pageSize
			};
		}
		$.ajax({
			type : "get",
			url : "/manager/stat/click/list",
			cache : false,
			dataType : "json",
			data: params
		}).done(function(result){
			if(result.isTrue) {
				var ps = result.ps;
				var data = new Array();
				owner.map_data = {};
				if(ps.items.length==0) {
					$.messager.alert("提示信息", "暂无数据！");
					return;
				}
				for(var i=0; i<ps.items.length; i++) {
					var obj = ps.items[i];
					owner.map_data[obj.clickId] = obj;
					data.push(owner.formatItem(obj));
				}
				owner.dom_table.datagrid("loadData", {
					"total": ps.totalCount,
					"rows": data
				}); 
			} else {
				$.messager.alert("提示信息", result.message);
			}
		}).fail(function(){
			$.messager.alert("提示信息", "网络繁忙，请稍后再试！");
		});
	};
	
	
	
	
	
	
	
	
	
	
	
	
	
	
};